package com.hanqian.kepler.core.vo;

import cn.hutool.core.convert.Convert;
import com.hanqian.kepler.core.entity.primary.core.TargetDesc;
import com.hanqian.kepler.core.entity.primary.sys.Dict;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
 * newFile
 * ============================================================================
 * author : dzw
 * createDate:  2020/12/31 。
 * ============================================================================
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WikiDescVo {

	//指标定义字典id
	String dictId;

	//指标定义字典name
	String dictName;

	//详细描述列表
	List<WikiTargetDescVo> wikiTargetDescVoList;

	public WikiDescVo(Dict targetDescDict, List<WikiTargetDescVo> wikiTargetDescVoList) {
		this.dictId = targetDescDict.getId();
		this.dictName = targetDescDict.getName();
		this.wikiTargetDescVoList = wikiTargetDescVoList;
	}

	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	public static class WikiTargetDescVo {

		//指标卡片id
		private String targetId;

		//自身id
		private String id;

		//描述内容
		private String content;

		//描述解释
		private String explanation;

		//是否存在数据元
		private String ifYuan;

		//指标数据元
		private String yuan;

		//最后更新时间（业务级别内的最后更新时间）
		private Date lastUpdateTime;

		//当前版本
		private String version;
		private Integer versionIndex;

		//是否已经点过赞
		private boolean ifZan;

		//点赞数量
		private String zanCount;

		public WikiTargetDescVo(TargetDesc targetDesc, boolean ifZan) {
			this.targetId = targetDesc.getTarget()!=null ? targetDesc.getTarget().getId() : "";
			this.id = targetDesc.getId();
			this.content = targetDesc.getContent();
			this.explanation = targetDesc.getExplanation();
			this.ifYuan = targetDesc.getYuan();
			this.lastUpdateTime = targetDesc.getLastUpdateTime();
			this.version = targetDesc.getVersion();
			this.versionIndex = targetDesc.getVersionIndex();
			this.zanCount = targetDesc.getZanCount()!=null ? Convert.toStr(targetDesc.getZanCount()) : "0";
			this.ifZan = ifZan;
		}

	}

}
